package com.easemob.chat;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.util.Log;
import com.easemob.chat.core.f;
import com.easemob.chat.core.f.c;
import com.easemob.chat.core.k;
import com.easemob.util.EMLog;

public class EMChatConfig
{
  private static final String TAG = "conf";
  private static final String CONFIG_EASEMOB_APPKEY = "EASEMOB_APPKEY";
  private static final String CONFIG_EASEMOB_CHAT_ADDRESS = "EASEMOB_CHAT_ADDRESS";
  private static final String CONFIG_EASEMOB_CHAT_DOMAIN = "EASEMOB_CHAT_DOMAIN";
  private static final String CONFIG_EASEMOB_GROUP_DOMAIN = "EASEMOB_GROUP_DOMAIN";
  private static final String CONFIG_EASEMOB_API_URL = "EASEMOB_API_URL";
  static String DOMAIN = "easemob.com";
  static String DOMAIN_SUFFIX = "@easemob.com";
  static String MUC_DOMAIN = "conference.easemob.com";
  static String MUC_DOMAIN_SUFFIX = "@conference.easemob.com";
  static final String UUID = "uuid";
  static final String SHARE_SERCRET = "share-secret";
  static final String TOKEN_ENTITY = "entities";
  public String APPKEY = null;
  String AccessToken = null;
  Context applicationContext = null;
  boolean isHttps = false;
  boolean isGetBlackList = false;
  public static boolean debugMode = false;
  private static boolean debugTrafficMode = false;
  private static EMChatConfig instance = null;

  public static EMChatConfig getInstance()
  {
    if (instance == null)
      instance = new EMChatConfig();
    return instance;
  }

  public static boolean isDebugTrafficMode()
  {
    return debugTrafficMode;
  }

  boolean loadConfig(Context paramContext)
  {
    this.applicationContext = paramContext;
    String str1 = this.applicationContext.getPackageName();
    ApplicationInfo localApplicationInfo = null;
    Object localObject1 = null;
    Object localObject2 = null;
    try
    {
      localApplicationInfo = this.applicationContext.getPackageManager().getApplicationInfo(str1, 128);
    }
    catch (PackageManager.NameNotFoundException localNameNotFoundException)
    {
      EMLog.e("conf", localNameNotFoundException.getMessage());
      throw new RuntimeException("找不到ApplicationInfo");
    }
    Bundle localBundle = localApplicationInfo.metaData;
    if (localBundle == null)
      throw new RuntimeException("请确认meta属性写在清单文件里的application节点以内");
    String str2 = localBundle.getString("EASEMOB_APPKEY");
    if ((str2 == null) && (this.APPKEY == null))
    {
      Log.e("conf", "EASEMOB_APPKEY is not set in AndroidManifest file");
      throw new RuntimeException("必须在清单文件里填写正确的EASEMOB_APPKEY");
    }
    this.APPKEY = str2;
    EMLog.i("conf", "EASEMOB_APPKEY is set to:" + this.APPKEY);
    String str3 = localBundle.getString("EASEMOB_CHAT_ADDRESS");
    if (str3 != null)
      localObject1 = str3;
    String str4 = localBundle.getString("EASEMOB_API_URL");
    if (str4 != null)
      localObject2 = str4;
    String str5 = localBundle.getString("EASEMOB_CHAT_DOMAIN");
    if (str5 != null)
      DOMAIN = str5;
    DOMAIN_SUFFIX = "@" + DOMAIN;
    String str6 = localBundle.getString("EASEMOB_GROUP_DOMAIN");
    if (str6 != null)
      MUC_DOMAIN = str6;
    MUC_DOMAIN_SUFFIX = "@" + MUC_DOMAIN;
    if ((localObject1 != null) && (!localObject1.equals("")))
      k.a().a(localObject1);
    if ((localObject2 != null) && (!localObject2.equals("")))
      k.a().b(localObject2);
    printConfig();
    return true;
  }

  private void printConfig()
  {
    EMLog.d("conf", " APPKEY:" + this.APPKEY + " CHATSERVER:" + k.a().f() + " domain:" + DOMAIN);
    EMLog.d("conf", "STORAGE_URL:" + k.a().h());
  }

  public String getDomain()
  {
    return DOMAIN;
  }

  public Context getApplicationContext()
  {
    return this.applicationContext;
  }

  public String getStorageUrl()
  {
    return f.a().c().a;
  }

  public String getHttpHost()
  {
    String str = f.a().c().a;
    if (this.isHttps)
      return "https://" + str;
    return "http://" + str;
  }

  public boolean getIsHttps()
  {
    return this.isHttps;
  }

  void setEnv(EMEnvMode paramEMEnvMode)
  {
    k.a().a(paramEMEnvMode);
  }

  public EMEnvMode getEnvMode()
  {
    return k.a().p();
  }

  public static enum EMEnvMode
  {
    EMSandboxMode, EMProductMode, EMDevMode;
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     com.easemob.chat.EMChatConfig
 * JD-Core Version:    0.6.1
 */